<include file="Common:header" />
<body>
    <!--面包屑导航 开始-->
    <div class="crumb_warp">
        <!--<i class="fa fa-bell"></i> 欢迎使用登陆网站后台，建站的首选工具。-->
        <i class="fa fa-home"></i> <a href="{:U(MODULE_NAME.'/Index/info')}">首页</a> &raquo; 角色管理
    </div>
    <!--面包屑导航 结束-->
    <!--搜索结果页面 列表 开始-->
    <form action="#" method="post">
        <div class="result_wrap">
            <!--快捷导航 开始-->
            <div class="result_content">
                <div class="short_wrap">
                    <a href="{:U(MODULE_NAME.'/Access/addRole')}"><i class="fa fa-plus"></i>添加角色</a>
                    <a href="{:U(MODULE_NAME.'/Access/role')}"><i class="fa fa-refresh"></i>刷新页面</a>
                </div>
            </div>
            <!--快捷导航 结束-->
        </div>
        <div class="result_wrap">
            <div class="result_content">
                <table class="list_tab">
                    <tr>
                        <th class="tc">排序</th>
                        <th class="tc">ID</th>
                        <th class="tc">角色名称</th>
                        <th class="tc">角色描述</th>
                        <th class="tc">角色状态</th>
                        <th class="tc">操作</th>
                    </tr>
                    <foreach name="role" item="v">
                        <td class="tc" width="5%">
                            <input type="text" name="ord[]" value="{$v.sort}" onchange="changeBylink(this,{$v['id']})" >
                        </td>
                            <td class="tc">{$v.id}</td>
                            <td class="tc">{$v.name}</td>
                            <td class="tc">{$v.remark}</td>
                            <td class="tc"><if condition="$v['status']">开启<else /><span style="color: red">关闭</span></if></td>
                            <td class="tc"><a href="{:U(MODULE_NAME.'/Access/editRole',array('id'=>$v['id']))}">修改</a>&nbsp;&nbsp;<a href="javascript:;" onclick="delRole({$v['id']});">删除</a>&nbsp;&nbsp;<a href="{:U(MODULE_NAME.'/Access/access',array('rid'=>$v['id']))}">配置权限</a></td>
                        </tr>
                    </foreach>
                </table>
                <div class="flickr">{$page}</div>
            </div>
        </div>
    </form>
    <!--搜索结果页面 列表 结束-->
</body>
</html>
<script type="text/javascript">

    //异步排序修改
    function changeBylink(obj,id){
        var sort = $(obj).val();
        $.post("{:U(MODULE_NAME.'/Access/change')}",{'sort':sort,'id':id},function(data){
            if(data.status==1){
                layer.alert(data.info, {icon: 6});
                $('.layui-layer-btn .layui-layer-btn0').click(function(){
                    location.href=location.href;
                });
                //location.href=location.href;
            }else{
                layer.alert(data.info, {icon: 5});
            }
        });
    }


    //异步删除
    function delRole(id){
        //layer询问框
        layer.confirm('您确定要进行删除操作？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.post('{:U("Access/deleteRole")}',{'id':id},function(data){
                if(data.status==1){
                    layer.msg(data.info);
                    location.href="{:U('Access/role')}";
                }else{
                    layer.msg(data.info);
                }
            });
        });
    }
</script>